<html>
<head>
<title>配置推送渠道</title> 
{{>/WEB-INF/pages/common/meta_base.part.html}}
{{>/WEB-INF/pages/common/refs_base.part.html}}
<script>
    $(document).ready(function() {
		// 聚焦第一个输入框
		$("#appId").focus();
		// 为inputForm注册validate函数
		$("#inputForm").validate();
		$(":checkbox._cfg_option").on("change", function(evt) {
			var fs = $(evt.target).parents("fieldset")[0];
			$(":input:not(._cfg_option)", fs).attr('disabled', !evt.target.checked);
		});
		// 提交时检查
		$("#inputForm").submit(function(evt) {
			var form = $(this);
			if(form.valid() == false){
				evt.preventDefault();
				return false;
			}
			var n=$(":input._cfg_option:checked", form).length;
			if(n == 0) {
				bootbox.alert("<div class='alert alert-error'><h4>至少填写一项才能提交</h4></div>")
				evt.preventDefault();
				return false;
			}
			return true;
		});
	});
</script>
</head>
<body>
{{>/WEB-INF/pages/common/layout_header.part.html}}
	<div class="container">
		<ul class="breadcrumb">
		  <li><a href="{{ctx}}">首页</a></li>
		  <li><a href="{{ctx}}/system/cloud">云服务</a></li>
		  <li class="active">配置推送渠道</li>
		</ul>
		<hr class="hr1">
		<div class="hr-10"></div>
		<div class="hr-10"></div>
		<div class="hr-10"></div>
		<form id="inputForm" action="{{ctx}}/push/config/channel" method="post" enctype="multipart/form-data" class="form-horizontal">
			<div class="form-group">
				<label for="appId" class="control-label col-sm-2">应用标识:</label>
				{{^create}}
				<div class="col-sm-10">
					<p class="form-control-static text-primary"><strong>{{app.app_name}}</strong></p>
					<input type="hidden" name="appId" value="{{appId}}"/>
				</div>
				{{/create}}
				{{#create}}
				<div class="col-sm-4">
					{{#app}}
					<p class="form-control-static text-primary"><strong>{{app_name}}</strong></p>
					{{/app}}
					{{^app}}
					<select name="appId" class="input-large required">
						{{#apps}}
						<option value="{{id}}">
							{{app_name}}
						</option>
						{{/apps}}
					</select>
					{{/app}}
				</div>
				{{/create}}
				<input type="hidden" name="appKey" value="{{appKey}}"/>
			</div>
			{{#apnsForm}}
			<fieldset id="apns">
				<legend style="padding-left:10%;">
					<label class="checkbox">
					<label class="mylabel"></label>
					<input type="checkbox" id="chkbox_apns" class="_cfg_option" checked><h4>APNS生产环境推送配置</h4></label>
				</legend>
				<div class="form-group">
					<label for="certFile" class="control-label col-sm-2">证书文件:</label>
					<div class="col-sm-4">
						<input type="file" id="certFile" name="apns.certFile" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label for="certPassword" class="control-label col-sm-2">证书密码:</label>
					<div class="col-sm-4">
						<input type="password" id="certPassword" name="apns.certPassword" class="form-control required" />					
					</div>
				</div>
				<div class="form-group">
					<label for="certPassword1" class="control-label col-sm-2">再次输入证书密码:</label>
					<div class="col-sm-4">
						<input type="password" id="certPassword1" name="certPassword1" class="form-control required" />
					</div>
				</div>
			</fieldset>
			{{/apnsForm}}
			{{#apnsSandboxForm}}
			<fieldset id="apns_sandbox">
				<legend style="padding-left:10%;">
					<label class="checkbox"><input type="checkbox" id="chkbox_apns_sandbox" class="_cfg_option" checked><h4>APNS Sandobx环境推送配置</h4></label>
				</legend>
				<div class="form-group">
					<label for="certFile" class="control-label col-sm-2">证书文件:</label>
					<div class="col-sm-4">
						<input type="file" id="certFile" name="apnsSandbox.certFile" class="form-control" />
					</div>
				</div>
				<div class="form-group">
					<label for="certPassword" class="control-label col-sm-2">证书密码:</label>
					<div class="col-sm-4">
						<input type="password" id="certPassword" name="apnsSandbox.certPassword" class="form-control required" />
					</div>
				</div>
				<div class="form-group">
					<label for="certPassword1" class="control-label col-sm-2">再次输入证书密码:</label>
					<div class="col-sm-4">
						<input type="password" id="certPassword2" name="certPassword2" class="form-control required" />
					</div>
				</div>
			</fieldset>
			{{/apnsSandboxForm}}
			{{#openfireForm}}
			<fieldset id="openfire">
				<legend style="padding-left:10%;">
					<label class="checkbox"><input type="checkbox" id="chkbox_openfire"  class="_cfg_option" checked><h4>Openfire推送配置</h4></label>
				</legend>
				<div class="form-group">
					<label for="username" class="control-label col-sm-2">登录名:</label>
					<div class="col-sm-4">
						<input type="text" id="username" name="openfire.username" value="{{openfire.username}}" 
							class="form-control required"/>
					</div>
				</div>
				<div class="form-group">
					<label for="openfirePassword" class="control-label col-sm-2">登录密码:</label>
					<div class="col-sm-4">
						<input type="password" id="openfirePassword" name="openfire.password"
							class="form-control" required/>
					</div>
				</div>
				<div class="form-group">
					<label for="openfirePassword1" class="control-label col-sm-2">再次输入登录密码:</label>
					<div class="col-sm-4">
						<input type="password" id="openfirePassword1" name="openfirePassword1"
							class="form-control required" />
					</div>
				</div>
			</fieldset>
			{{/openfireForm}}
			{{#instantForm}}
			<fieldset id="instant">
				<legend style="padding-left:10%;">
					<label class="checkbox">
						<input type="checkbox" id="chkbox_instant" class="_cfg_option" checked><h4>instant推送配置</h4>
					</label>
				</legend>
				<div class="form-group">
					<label for="username" class="control-label col-sm-2"></label>
					<div class="col-sm-4"> <!-- style="visibility:hidden" -->
						<input type="hidden" name="instant.checked" value="{{instant.checked}}"/>
					</div>
				</div>
			</fieldset>
			{{/instantForm}}
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
				<button id="submit_btn" class="btn btn-primary" type="submit">提交</button>&nbsp; 
				<button id="cancel_btn" class="btn btn-default" type="button" value="返回" onclick="history.back()">返回</button>
				</div>
			</div>
			<input type="hidden" name="redirect" value="{{redirect}}"/>
		</form>
		{{>/WEB-INF/pages/common/layout_footer.part.html}}
	</div>
</body>
</html>
